// http://www.npedi.com/ediportal-web/common/js/edi.util.js

/*
*码头堆场代码名称对照
*/
function getPortCN(code){
	var result = "";
	
	if(code=="ALTCNB"){
		result = "安联储运";
	}else if(code=="B2SCT"){
		result = "北仑山码头";
	}else if(code=="BDNLPG"){
		result = "百地年";
	}else if(code=="BLCT"){
		result = "NBCT(二期)";
	}else if(code=="BLCT2"){
		result = "北二集司(三期)";
	}else if(code=="BLCT3"){
		result = "港吉(四期)";
	}else if(code=="BLCTCFS"){
		result = "通达公司";
	}else if(code=="BLCTMS"){
		result = "梅山码头";
	}else if(code=="BLCTMSCFS"){
		result = "四海物流";
	}else if(code=="BLCTYD"){
		result = "远东(五期)";
	}else if(code=="BLCTZS"){
		result = "大榭招商(CMICT)";
	}else if(code=="BLHH2"){
		result = "北二司(BLHH2)";
	}else if(code=="CSCFS"){
		result = "长胜堆场";
	}else if(code=="DXCTE"){
		result = "大榭信业码头";
	}else if(code=="JIAYANG"){
		result = "佳洋物流";
	}else if(code=="LONGZHOU"){
		result = "龙洲物流";
	}else if(code=="NBAD"){
		result = "安达堆场";
	}else if(code=="NBDNL"){
		result = "东南物流";
	}else if(code=="NBNX"){
		result = "宁翔储运";
	}else if(code=="NBRY"){
		result = "瑞源堆场";
	}else if(code=="NBZR"){
		result = "宁波中燃";
	}else if(code=="NDCC"){
		result = "大港堆场";
	}else if(code=="NHCC"){
		result = "和欣货柜";
	}else if(code=="NSSL"){
		result = "新世洋物流";
	}else if(code=="SXZG"){
		result = "三星重工";
	}else if(code=="WHMT"){
		result = "万华码头";
	}else if(code=="WZCT"){
		result = "温州港区";
	}else if(code=="XUNDA"){
		result = "迅达仓储";
	}else if(code=="YGHAL"){
		result = "永港海安";
	}else if(code=="YZCT"){
		result = "甬舟码头";
	}else if(code=="ZHCT"){
		result = "镇司(ZHCT)";
	}else if(code=="ZIT"){
		result = "乍浦码头";
	}else if(code=="ZRCCJHC"){
		result = "中石化镇海";
	}else if(code=="ZHGC"){
		result = "镇司(ZHGC)";
	}else{
		result = code;
	}
	
	return result;
}

/*
*整拼箱代码名称对照
*/
function getZPXCN(code){
	var result = "";
	
	if(code=="F"){
		result = "整箱";
	}else if(code=="L"){
		result = "拼箱";
	}else if(code=="E"){
		result = "空箱";
	}
	
	return result;
}

/*
*调用统一提示弹出框
*/
function showTips(tips){
	$("#tips").html(tips);
	$("#tipswin").dialog("open");
}

/*
*如果为null或undefined，返回空""
*/
function getEmptyResult(result){
	if(result == null || result == undefined || result == "#"){
		return "";
	}else{
		return result;
	}
	
}

/*
*返回格式化后的时间字符串
*/
function getFormatTimeStr(timestr){
	if(timestr == null || timestr == undefined || timestr == "" || timestr==" "){
		return "";
	}else{
		if(getStrRealLength(timestr)<12){
			
			timestr += "00000000000";
			
		}
		
		_tmpYear = timestr.substring(0,4);
		_tmpMonth = timestr.substring(4,6);
		_tmpDay = timestr.substring(6,8);
		_tmpHour = timestr.substring(8,10);
		_tmpMin = timestr.substring(10,12);
		
		return _tmpYear + "-" + _tmpMonth + "-" + _tmpDay + " " + _tmpHour + ":" + _tmpMin;
	}
	
}

/*
*由于JS原先的长度中文跟英文一样一个字符为1个长度。
*获得字符串实际长度，中文2，英文1
*/
function getStrRealLength(str){
    ///<summary>获得字符串实际长度，中文2，英文1</summary>
    ///<param name="str">要获得长度的字符串</param>
    var realLength = 0, len = str.length, charCode = -1;
    for (var i = 0; i < len; i++) {
        charCode = str.charCodeAt(i);
        if (charCode >= 0 && charCode <= 128) realLength += 1;
        else realLength += 2;
    }
    return realLength;
}

/*
*海关查验
*/
function getCY(code){
	var result = "";
	
	if(code=="OK"){
		result = "移箱完成";
	}else if(code=="CM"){
		result = "能够移箱";
	}else if(code=="UM"){
		result = "不能移箱";
	}else if(code=="OR"){
		result = "撤销完成";
	}else if(code=="CR"){
		result = "能够撤销";
	}else if(code=="UR"){
		result = "不能撤销";
	}else if(code=="OT"){
		result = "完成归位";
	}else if(code=="C"){
		result = "查验";
	}else if(code=="P"){
		result = "拼箱";
	}else if(code=="R"){
		result = "撤销";
	}else if(code=="G"){
		result = "归位";
	}else if(code=="Y"){
		result = "收到归位指令";
	}else if(code=="N"){
		result = "归位指令接收异常";
	}else if(code=="W"){
		result = "有其他原因无法归位";
	}else if(code=="B"){
		result = "其他异常";
	}else if(code=="S"){
		result = "集装箱归位完成";
	}
	
	
	return result;
}

/*
*国检指令
*/
function getCIQ(code){
	var result = "";
	
	if(code=="0"){
		result = "放行不成功";
	}else if(code=="CM"){
		result = "1";
	}else if(code=="2"){
		result = "卫生完毕";
	}else if(code=="3"){
		result = "移箱指令";
	}else if(code=="4"){
		result = "移箱到位";
	}else if(code=="5"){
		result = "可以放行";
	}else if(code=="6"){
		result = "放行成功";
	}else if(code=="7"){
		result = "放射性检测";
	}else if(code=="8"){
		result = "放射性检测完成";
	}else if(code=="9"){
		result = "查验完毕";
	}else if(code=="I"){
		result = "进行卫生处理";
	}else if(code=="J"){
		result = "卫生处理完成";
	}else if(code=="H"){
		result = "卫生处理预处理完成";
	}else if(code=="D"){
		result = "截留";
	}else if(code=="E"){
		result = "截留成功";
	}else if(code=="A"){
		result = "申请转场";
	}else if(code=="B"){
		result = "可以转场";
	}else if(code=="C"){
		result = "转场成功";
	}
	return result;
}

//航向
function getDIRECTION(direction){
	if(direction=="I"){
		return "进口"	;	
	}else if(direction=="E"){
		return "出口";
	}else{
		return "";
	}
}